from rest_framework import serializers
from fdfs_client.client import Fdfs_client

from goods.models import Brand
from django.conf import settings


# def storagePic(content):
#     conn = Fdfs_client(settings.FILE_CONFIG)
#     ret = conn.upload_by_buffer(content)
#
#     return ret


class BrandSerializer(serializers.ModelSerializer):
    class Meta:
        model = Brand
        fields = "__all__"

    # def validate(self, attrs):
    #     logo = attrs.pop("logo")
    #     text = logo.read()
    #     ret = storagePic(text)
    #
    #     status = ret.get("Status")
    #     if status != 'Upload successed.':
    #         serializers.ValidationError("上传失败")
    #     attrs["logo"] = ret.get("Remote file_id")
    #     return attrs
    #


# id name logo first_letter